package com.itcast.n1_内存调优;

import java.io.IOException;
import java.util.ArrayList;

public class Test01_解决内存泄漏_内存泄漏导致内存持续增长最终内存溢出{
    public static void main(String[] args) throws IOException {
        System.in.read();
        int count = 0;
        ArrayList<Outer1.Inner1> inner1s = new ArrayList<>();
        while (true){
            System.out.println(++count);
            inner1s.add(new Outer1().new Inner1());
        }
    }
}
class Outer1 {
    private byte[] bytes = new byte[1024 * 1024]; //外部类持有数据
    private static String name  = "测试";
    class Inner1 {
        private String name;
        public Inner1() {
            this.name = Outer1.name;
        }
    }
}
